<?php
date_default_timezone_set("Asia/Saigon");
require_once 'config.php';
require_once 'init.php';

function make_lib($dir)
{
	$files = CFile($dir)->files();
	$st = '';
	foreach($files as $file)
	{
		if(is_file($dir.'/'.$file))
		{
			if(strpos($file, '.php'))
			{
				$st .= CFile($dir.'/'.$file)->get();
			}
		}
		elseif($file != '.svn' and $file != 'utils')
		{
			$st .= make_lib($dir.'/'.$file);
		}
	}
	return $st;
}
function remove_comments($code)
{
	//return $code;
	return str_replace('<?php\').\'}else{\'.($in_php','<?php\').\' }else{ \'.($in_php',preg_replace(array('/([^\:])\/\/[^\n]*/','/;\n\s*/','/\n\s*\n/','/\s*\{\s*/','/\s*\}\s*/','/\/\*\*[^\*]*\*+([^\/\*][^\*]*\*+)*\//'), array('\\1',';',"\n",'{','}',''),$code));
}
CFile('lib.php')->put(remove_comments('<?php error_reporting(E_ALL | E_NOTICE | E_STRICT);
$GLOBALS[\'start_time\'] = microtime(true);?>'.make_lib('lib').'<?php CSystem::start();?>'));
?>